package com.wgj.android.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
import android.widget.CompoundButton;

import com.wgj.android.R;
import com.wgj.android.utils.AccessibilityUtil;
import com.wgj.android.widget.NumberEditView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;

/**
 * Created by Administrator on 2017/11/1.
 */

public class FriendsCleanSettingActivity extends AppCompatActivity {
    @BindView(R.id.isOpneSound)
    SwitchCompat isOpneSoundCompat;
    @BindView(R.id.isOpenWeiXi)
    SwitchCompat isOpenWeiXiCompat;
    @BindView(R.id.isOpenVibrate)
    SwitchCompat isOpenVibrateCompat;
    @BindView(R.id.isAutoDel)
    SwitchCompat isAutoDelCompat;

    @BindView(R.id.globaTime)
    NumberEditView globaTimeView;



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.friends_clean_setting_activity);
        ButterKnife.bind(this);
        init();
    }

    private  void init(){
         isAutoDelCompat.setChecked(AccessibilityUtil.isAutoDel());
         isOpenVibrateCompat.setChecked(AccessibilityUtil.isOpenVibraie());
         isOpenWeiXiCompat.setChecked(AccessibilityUtil.isOpenWeiXi());
         isOpneSoundCompat.setChecked(AccessibilityUtil.isOpenSound());
         globaTimeView.setValue(AccessibilityUtil.getSleepTime());
         globaTimeView.setNumberListener(new NumberEditView.NumberListener() {
             @Override
             public void onValueChanged(int value) {
                  AccessibilityUtil.setSellpTime(value);
             }
         });
    }

    @OnCheckedChanged({R.id.isAutoDel,R.id.isOpenVibrate,R.id.isOpenWeiXi,R.id.isOpneSound})
    public void onSettingChanged(CompoundButton view,boolean isOpen){
         switch (view.getId()){
             case R.id.isAutoDel:
                 AccessibilityUtil.setIsAutoDel(isOpen);
                 break;
             case R.id.isOpenVibrate:
                 AccessibilityUtil.setIsOpenVibrate(isOpen);
                 break;
             case R.id.isOpenWeiXi:
                 AccessibilityUtil.setOpenXeiXi(isOpen);
                 break;
             case R.id.isOpneSound:
                 AccessibilityUtil.setIsOpenSound(isOpen);
                 break;
             default:
                 break;
         }
    }



}
